<?php
namespace Home\Controller;
use Think\Controller;
class NewsController extends Controller {
	public function index(){
		$news=M('new');
		$total = $news->count();
		$page = new \Think\Page($total, 10);
		$page->setConfig('first', '首页');
		$page->setConfig('prev', '上一页');
		$page->setConfig('next', '下一页');
		$page->setConfig('last', '尾页');
		$this->newsinfo = $news->limit($page->firstRow, $page->listRows)->order('add_time desc')->select();
		$this->assign('page', $page->show());


		 $cate=D('cate');
        $ca=$cate->select();
        //var_dump($cates);exit;
        $this->assign('ca',$ca);

		
		$this->display();
	}
	
	public function show(){
		$id=I('id');
		$news=M('new');
		//var_dump($news); exit;
		$this->newinfo=$news->find($id);
		
		$this->display();
	}
}